<style lang="less">
  @import './login.less';
</style>

<template>
  <div class="login">
    <div class="login-title">CGMCARE</div>
    <div class="login-con">
      <div class="login-title-header">300家医疗机构的共同选择</div>
      <Card icon="log-in" :bordered="false">
        <div class="title">CGMCARE-糖尿病管理云平台</div>
        <div class="form-con">
          <login-form @on-success-valid="handleSubmit"></login-form>
          <p class="login-tip">输入任意用户名和密码即可</p>
        </div>
      </Card>
    </div>
    <div class="foot">华云健康科技有限公司</div>
  </div>
</template>

<script>
import LoginForm from '_c/login-form'
// import { loginAction } from '@/api/login'
import { mapActions } from 'vuex'
export default {
  components: {
    LoginForm
  },
  created () {
    
  },
  mounted () {
    this.getUserInfo()
  },
  methods: {
    ...mapActions([
      'handleLogin',
      'getUserInfo'
    ]),
    handleSubmit ({ username, password }) {
      this.handleLogin({ username, password }).then(res => {
        if(res){
          this.getUserInfo().then(res => {
            this.$router.push({
              name: this.$config.homeName
            })
          })
        }
        // this.getUserInfo().then(res => {
        //   this.$router.push({
        //     name: this.$config.homeName
        //   })
        // })
      })
    }
  }
}
</script>

<style>

</style>
